﻿<?xml version="1.0" encoding="utf-8" ?>

<cls:class
	name="IdeCdDriveTrack"
	type="http://metalx.org/Storage/Ide/IdeCdDriveTrack"
	xmlns="http://metalx.org/Program"
	xmlns:cls="http://metalx.org/Class"
	xmlns:var="http://metalx.org/Variable"
	xmlns:obj="http://metalx.org/i386/Functions/Object"
	xmlns:sys="http://metalx.org/i386/Functions/System"
	xmlns:cat="http://metalx.org/i386/Functions/Catalog"
	xmlns:str="http://metalx.org/i386/Functions/String"
	xmlns:int="http://metalx.org/i386/Functions/Integer"
	xmlns:bool="http://metalx.org/i386/Functions/Boolean"
	xmlns:lst="http://metalx.org/i386/Functions/List"
	xmlns:cd="http://metalx.org/i386/Functions/CdDrive"
	xmlns:hex="http://metalx.org/i386/Functions/Hexadecimal"
	xmlns:mm="http://metalx.org/i386/Functions/MemoryManager"
	xmlns:clsf="http://metalx.org/i386/Functions/Class"
	xmlns:pata="http://metalx.org/Pc/Pata/Ports"
	xmlns:status="http://metalx.org/Pc/Pata/Status"
	xmlns:drive="http://metalx.org/Pc/Pata/DriveSelect"
	xmlns:cmd="http://metalx.org/Pc/Pata/Commands"
	xmlns:cpu="http://metalx.org/Intel/80386/Operators"
	xmlns:op="http://metalx.org/Intel/80386/Operands"
	xmlns:imm="http://metalx.org/Intel/80386/Immediate"
	xmlns:math="http://metalx.org/Intel/80386/Math"
	xmlns:ari="http://metalx.org/Intel/80386/Arithmetic"
	xmlns:shift="http://metalx.org/Intel/80386/Shift"
	xmlns:logic="http://metalx.org/Intel/80386/Logic"
	xmlns:port="http://metalx.org/Pc/Ports"
	xmlns:pci="http://metalx.org/Pc/Pci/Ports"
	xmlns:cfg="http://metalx.org/Pc/Pci/Configuration"
	xmlns:dsk="http://metalx.org/Pc/Floppy/Ports"
	xmlns:fcmd="http://metalx.org/Pc/Floppy/Commands"
	xmlns:fdr="http://metalx.org/Pc/Floppy/DataRate"
	xmlns:fdo="http://metalx.org/Pc/Floppy/DigitalOutput"
	xmlns:fst="http://metalx.org/Pc/Floppy/Status"
	xmlns:kbd="http://metalx.org/Pc/Keyboard">

	<cls:field name="Drive" type="http://metalx.org/Reference" offset="0"/>
	<cls:field name="TrackNumber" type="http://metalx.org/Byte" offset="4"/>
	<cls:field name="StartMinute" type="http://metalx.org/Byte" offset="5"/>
	<cls:field name="StartSecond" type="http://metalx.org/Byte" offset="6"/>
	<cls:field name="StartFrame" type="http://metalx.org/Byte" offset="7"/>

	<var:integer id="bytesPerFrame">2352</var:integer>
	<var:integer id="framesPerSecond">75</var:integer>
	<var:integer id="secondsPerMinute">60</var:integer>

	<cls:method name="GetAudioReader" type="http://metalx.org/Storage/Ide/IdeCdDriveAudioReader">
		<cpu:CopyRegisterToOperand/>
		<op:DI-SIRegister/>

		<mm:CheckOut length="8"/>

		<obj:GetData/>

		<cpu:CopyOperandToRegister/>
		<op:AX-SIAddress/>
		
		<cpu:CopyRegisterToOperand/>
		<op:AX-DIAddress/>

		<cpu:ExclusiveOrOperandWithRegister/>
		<op:AX-AXRegister/>

		<cpu:ExclusiveOrOperandWithRegister/>
		<op:DX-DXRegister/>
		
		<cpu:ExclusiveOrOperandWithRegister/>
		<op:BX-BXRegister/>

		<cpu:CopyOperandToRegister8/>
		<op:AL-SIAddressPlusImmediate8/>
		<byte>5</byte>

		<cpu:ArithmeticDXAXOperandFunction/>
		<ari:MultiplyByImmediateAddress/>
		<addressOf ref="secondsPerMinute" type="Absolute32"/>

		<cpu:CopyOperandToRegister8/>
		<op:BL-SIAddressPlusImmediate8/>
		<byte>6</byte>

		<cpu:AddRegisterToOperand/>
		<op:BX-AXRegister/>

		<cpu:ArithmeticDXAXOperandFunction/>
		<ari:MultiplyByImmediateAddress/>
		<addressOf ref="framesPerSecond" type="Absolute32"/>

		<cpu:CopyOperandToRegister8/>
		<op:BL-SIAddressPlusImmediate8/>
		<byte>7</byte>

		<cpu:AddRegisterToOperand/>
		<op:BX-AXRegister/>

		<cpu:ArithmeticDXAXOperandFunction/>
		<ari:MultiplyByImmediateAddress/>
		<addressOf ref="bytesPerFrame" type="Absolute32"/>

		<cpu:CopyRegisterToOperand/>
		<op:AX-DIAddressPlusImmediate8/>
		<byte>4</byte>

		<obj:Create length="8" type="http://metalx.org/Storage/Ide/IdeCdDriveAudioReader"/>

		<cpu:ReturnToNearCaller/>
	</cls:method>

	<cls:method name="ToString" type="http://metalx.org/String">
		<cpu:CopyImmediateToDI/>
		<addressOf ref="className" type="Absolute32"/>
		
		<str:CreateObject/>
		
		<cpu:ReturnToNearCaller/>

		<var:string id="className">IDE CD Drive Track</var:string>
	</cls:method>

	<cls:method name="GetClass" type="http://metalx.org/Class">
		<cpu:CopyRegisterToOperand/>
		<op:DI-SIRegister/>

		<obj:GetType/>

		<cpu:CopyRegisterToOperand/>
		<op:SI-DIRegister/>

		<clsf:CreateObject/>

		<cpu:ReturnToNearCaller/>
	</cls:method>
</cls:class>